//index.js
const app = getApp();
var service = require('../../util/service');
Page({
  data: {
    avatarUrl: './user-unlogin.png',
    tabbar: {},
    userInfo: {},
    user:{},
    logged: false,
    takeSession: false,
    requestResult: ''
  },
  onLoad:function(){

  },
  onShow: function() {
    var user = app.userInfo;
    app.changeTabBar(); 
    //加载等级
    service.AJAX("smc/sys/LookupValueLine/listLookupValueLine.json", { "$valHdsCode": "SJX" }, res => {
      console.log(res);
      var dj = 1;
      var k = res.length;
      var syj = 0;
      for (var i = 0; i < res.length; i++) {
        if (user.buyLevelId >= res[i].valLnsResult) {
          dj = res[i].valLnsCode;
          syj = res[i].valLnsResult;
          k = i;
          break;
        }
      }
      if (k != 0) syj = res[k - 1].valLnsResult;
      if (k == 0) syj = "……";
      user.syj = syj;
      user.dj = dj;
      this.setData({
        avatarUrl: user.pic,
        user: user
      });
    }, err => { }, 'POST')
    // 获取用户信息
    // wx.getSetting({
    //   success: res => {
    //     if (res.authSetting['scope.userInfo']) {
    //       // 已经授权，可以直接调用 getUserInfo 获取头像昵称，不会弹框
    //       wx.getUserInfo({
    //         success: res => {
    //           console.log(user);
              
    //         }
    //       })
    //     }
    //   }
    // })
  }

})
